package com.barunsw.bwf.neoarena_erp.cm_common;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.barunsw.bwf.neoarena_erp.vo.CMCommonVo;

/**
 * Handles requests for the application home page.
 */
@Controller
@RequestMapping("/cm_common")
public class CMCommonController {
	private static final Logger logger = LoggerFactory.getLogger(CMCommonController.class);
	
	@Autowired
	CMCommonService cmCommonService;
	
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public @ResponseBody List<CMCommonVo> list(
			@RequestBody @RequestParam(value="companyCode", required=true) String companyCode,
			@RequestBody @RequestParam(value="majorCode", required=true) String majorCode,
			@RequestBody @RequestParam(value="word", required=false) String word
			) throws Exception {
		logger.debug(String.format("list?companyCode=%s&majorCode=%s&word=%s", companyCode, majorCode, word));
		
		CMCommonVo cmCommonVo = new CMCommonVo();
		cmCommonVo.setCompanyCode(companyCode);
		cmCommonVo.setMajorCode(majorCode);
		cmCommonVo.setWord(word);
		
		List<CMCommonVo> cmCommonList = cmCommonService.selectList(cmCommonVo);
		
		return cmCommonList;
	}
}
